using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ClientNetManager
{
    static ClientNetManager Instance = null;

    public static void Destroy()
    {
        if(null != Instance)
        {
            Instance.DestroyInternal();
            Instance = null;
        }
    }

    public static void Create(string ip,int port,long id = 9527)
    {
        Instance = new ClientNetManager(ip, port,id);
    }
    ClientNet clientNet;
    long id;

    ClientNetManager(string ip, int port, long id = 9527)
    {
        this.id = id;
        clientNet = new ClientNet(id);
        NetManager.Instance.Connect(clientNet,ip,port);
    }

    void DestroyInternal()
    {
        clientNet.Destroy();
    }

    public static void Send(Google.Protobuf.IMessage msg)
    {
        NetManager.Instance.Send(msg, Instance.id);
    }
}
